package com.nut.lmsc.api.admin;

import com.nut.lmsc.common.Result;
import com.nut.lmsc.entity.GoodsSpec;
import com.nut.lmsc.service.GoodsSpecService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Set;

@Slf4j
@RestController
@RequestMapping("/admin/goodsSpec")
public class GoodsSpecController {

    @Autowired
    private GoodsSpecService goodsSpecService;

    @GetMapping(value = "/goodsId/{goodsId}")
    public Result<List<GoodsSpec>> list(@PathVariable Integer goodsId) {
        return goodsSpecService.selectByGoodsId(goodsId);
    }

    @PostMapping
    public Result add(@RequestBody GoodsSpec goodsSpec) {
        return goodsSpecService.add(goodsSpec);
    }

    @PutMapping
    public Result update(@RequestBody GoodsSpec goodsSpec) {
        return goodsSpecService.updateById(goodsSpec);
    }

    @DeleteMapping
    public Result delete(@RequestBody Set<Integer> ids) {
        return goodsSpecService.deleteByIds(ids);
    }

}